#ifndef _FRAMEWORK_DEFS_H_
#define _FRAMEWORK_DEFS_H_

#include "zlgcan.h"
#include <iostream>
#include <map>

namespace zlg
{

typedef struct _DeviceInfo
{
    UINT device_type;  //设备类型
    UINT channel_count;//设备的通道个数
}DeviceInfo;

static const DeviceInfo kDeviceType[] = {
    {ZCAN_USBCAN1, 1},
    {ZCAN_USBCAN2, 2},
    {ZCAN_PCI9820I,2},
    {ZCAN_USBCAN_E_U, 1},
    {ZCAN_USBCAN_2E_U, 2},
    {ZCAN_USBCAN_4E_U, 4},
    {ZCAN_PCIE_CANFD_100U, 1},
    {ZCAN_PCIE_CANFD_200U, 2},
    {ZCAN_PCIE_CANFD_400U_EX, 4 },
    {ZCAN_USBCANFD_200U, 2},
    {ZCAN_USBCANFD_100U, 1},
    {ZCAN_USBCANFD_MINI, 1},
    {ZCAN_CANETTCP, 1},
    {ZCAN_CANETUDP, 1},
    {ZCAN_WIFICAN_TCP, 1},
    {ZCAN_WIFICAN_UDP, 1},
    {ZCAN_CLOUD, 1},
    {ZCAN_CANFDWIFI_TCP, 1},
    {ZCAN_CANFDWIFI_UDP, 1},
    {ZCAN_CANFDNET_TCP, 2},
    {ZCAN_CANFDNET_UDP, 2},
    {ZCAN_CANFDNET_400U_TCP, 4},
    {ZCAN_CANFDNET_400U_UDP, 4},
};

enum class UsbCanAbitDef : uint8_t
{
    UsbCanAbit_1Mbps   = 0,
    UsbCanAbit_800kbps = 1,
    UsbCanAbit_500kbps = 2,
    UsbCanAbit_250kbps = 3,
    UsbCanAbit_125kbps = 4,
    UsbCanAbit_100kbps = 5,
    UsbCanAbit_50kbps  = 6,
};

static const std::map<UsbCanAbitDef, uint32_t> kAbitTimingUSB =
{
    {UsbCanAbitDef::UsbCanAbit_1Mbps, 1000000},
    {UsbCanAbitDef::UsbCanAbit_800kbps, 800000},
    {UsbCanAbitDef::UsbCanAbit_500kbps, 500000},
    {UsbCanAbitDef::UsbCanAbit_250kbps, 250000},
    {UsbCanAbitDef::UsbCanAbit_125kbps, 125000},
    {UsbCanAbitDef::UsbCanAbit_100kbps, 100000},
    {UsbCanAbitDef::UsbCanAbit_50kbps, 50000},
};

enum class UsbCanDbitDef : uint8_t
{
    UsbCanDbit_5Mbps   = 0,
    UsbCanDbit_4Mbps   = 1,
    UsbCanDbit_2Mbps   = 2,
    UsbCanDbit_1Mbps   = 3,
};
static const std::map<UsbCanDbitDef, uint32_t> kDbitTimingUSB =
{
    {UsbCanDbitDef::UsbCanDbit_5Mbps, 5000000},
    {UsbCanDbitDef::UsbCanDbit_4Mbps, 4000000},
    {UsbCanDbitDef::UsbCanDbit_2Mbps, 2000000},
    {UsbCanDbitDef::UsbCanDbit_1Mbps, 1000000},
};

enum class PcieCanfdAbitDef : uint8_t
{
    UsbCanAbit_1Mbps   = 0,
    UsbCanAbit_800kbps = 1,
    UsbCanAbit_500kbps = 2,
    UsbCanAbit_250kbps = 3,
    UsbCanAbit_125kbps = 4,
};
static const std::map<PcieCanfdAbitDef, uint32_t> kAbitTimingPCIE =
{
    {PcieCanfdAbitDef::UsbCanAbit_1Mbps, 1000000},
    {PcieCanfdAbitDef::UsbCanAbit_800kbps, 800000},
    {PcieCanfdAbitDef::UsbCanAbit_500kbps, 500000},
    {PcieCanfdAbitDef::UsbCanAbit_250kbps, 250000},
    {PcieCanfdAbitDef::UsbCanAbit_125kbps, 125000},
};

enum class PcieCanfdDbitDef : uint8_t
{
    UsbCanAbit_8Mbps        = 0,
    UsbCanAbit_5Mbps_75     = 1,
    UsbCanAbit_5Mbps_87     = 2,
    UsbCanAbit_4Mbps        = 3,
    UsbCanAbit_2Mbps        = 4,
    UsbCanAbit_1Mbps        = 5,
};
static const std::map<PcieCanfdDbitDef, uint32_t> kDbitTimingPCIE =
{
    {PcieCanfdDbitDef::UsbCanAbit_8Mbps,    8000000},
    {PcieCanfdDbitDef::UsbCanAbit_5Mbps_75, 5000000},
    {PcieCanfdDbitDef::UsbCanAbit_5Mbps_87, 5000000},
    {PcieCanfdDbitDef::UsbCanAbit_4Mbps,    4000000},
    {PcieCanfdDbitDef::UsbCanAbit_2Mbps,    2000000},
    {PcieCanfdDbitDef::UsbCanAbit_1Mbps,    1000000},
};

enum class BaudrateDef : uint8_t
{
    Baudrate_1000000 = 0,//1M
    Baudrate_800000 = 1,
    Baudrate_500000 = 2,
    Baudrate_250000 = 3,
    Baudrate_125000 = 4,
    Baudrate_100000 = 5,
    Baudrate_50000 = 6,
    Baudrate_20000 = 7,
    Baudrate_10000 = 8,
    Baudrate_5000 = 9,
    Baudrate_0 = 10
};

static const std::map<BaudrateDef, uint32_t> kBaudrate =
{
    {BaudrateDef::Baudrate_1000000, 1000000},
    {BaudrateDef::Baudrate_800000,  800000},
    {BaudrateDef::Baudrate_500000,  500000},
    {BaudrateDef::Baudrate_250000,  250000},
    {BaudrateDef::Baudrate_125000,  125000},
    {BaudrateDef::Baudrate_100000,  100000},
    {BaudrateDef::Baudrate_50000,   50000},
    {BaudrateDef::Baudrate_20000,   20000},
    {BaudrateDef::Baudrate_10000,   10000},
    {BaudrateDef::Baudrate_5000,    5000},
    {BaudrateDef::Baudrate_0,       0},
};

}

#endif
